<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 100px;
        height: 100px;
        background-color: red;
        margin-bottom: 20px;
      }
      .box2 {
        width: 100px;
        height: 100px;
        background-color: pink;
        margin-bottom: 20px;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <!-- 动态class -->
      <!-- :class="{css类名：布尔值}" -->
      <!-- 当布尔值为true时，会添加对应的样式，否则不添加 -->
      <div class="box" :class="{box2: isPink}" @click="isPink = !isPink"></div>
      <!-- 动态style -->
      <div
        :style="{backgroundColor:myColor?'pink':'red'}"
        @click="myColor = !myColor"
      >
        123
      </div>
    </div>
    <!-- 引入vue -->
    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          isPink: false,
          myColor: false,
        },
        methods: {},
      });
    </script>
  </body>
</html>
